package 共享锁实现.javaapilock;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;

import java.util.concurrent.CountDownLatch;

/**
 * author Veng Su
 * email  1344114844@qq.com
 * date   18-9-17 下午12:35
 * lock的watcher事件
 */
public class LockWatcher implements Watcher {
    private CountDownLatch countDownLatch;

    public LockWatcher(CountDownLatch countDownLatch) {
        this.countDownLatch = countDownLatch;
    }

    @Override
    public void process(WatchedEvent watchedEvent) {
            if (watchedEvent.getType()==Event.EventType.NodeDeleted){
                countDownLatch.countDown();
            }
    }
}
